
import { setStorageToken, removeStorageToken, getStorageToken } from '@/utils/storage'

export default {

  // 命名空间
  namespaced: true,

  // 数据
  state: {
    // token: JSON.parse(localStorage.getItem('hm-newa-token')) || {}
    token: getStorageToken()
  },

  // 修改数据
  mutations: {
    setToken(state, payload) {
      state.token = payload

      // token 本地存储
      // localStorage.setItem('hm-newa-token', JSON.stringify(payload))
      setStorageToken(payload)
    },

    removeToken(state) {
      state.token = {}

      // 把本地存储token删除
      removeStorageToken()
    }
  },

  getters: {
  },
  actions: {
  }

}
